import configparser
import re

rectnum = 2
rect_1 = "10x10+10+10"
rect_2 = "10x10+30+30"
rect_3 = "10x10+50+10"
rect_4 = "10x10+70+10"
rect_5 = "10x10+90+10"
rect_6 = "10x10+110+10"
rect_7 = "10x10+130+10"
rect_8 = "10x10+150+10"
rect_9 = "10x10+170+10"
rect_10 = "10x10+190+10"
sleeptime = 60

def load():
    conf = configparser.ConfigParser()
    conf.read('config.ini', encoding='utf-8')
    global rectnum
    global rect_1
    global rect_2
    global rect_3
    global rect_4
    global rect_5
    global rect_6
    global rect_7
    global rect_8
    global rect_9
    global rect_10
    global sleeptime
    rectnum = int(conf.get('rects', 'rectnum'))
    rect_1 = conf.get('rects', 'rect_1')
    rect_2 = conf.get('rects', 'rect_2')
    rect_3 = conf.get('rects', 'rect_3')
    rect_4 = conf.get('rects', 'rect_4')
    rect_5 = conf.get('rects', 'rect_5')
    rect_6 = conf.get('rects', 'rect_6')
    rect_7 = conf.get('rects', 'rect_7')
    rect_8 = conf.get('rects', 'rect_8')
    rect_9 = conf.get('rects', 'rect_9')
    rect_10 = conf.get('rects', 'rect_10')
    sleeptime = conf.get('control', 'sleeptime')
def gets(i):
    if i==0:
        return rectnum
    elif i==1:
        return rect_1
    elif i==2:
        return rect_2
    elif i==3:
        return rect_3
    elif i==4:
        return rect_4
    elif i==5:
        return rect_5
    elif i==6:
        return rect_6
    elif i==7:
        return rect_7
    elif i==8:
        return rect_8
    elif i==9:
        return rect_9
    elif i==10:
        return rect_10
    elif i==11:
        return sleeptime
def geotoxy(geo,xys):
    tmp=re.split(r'[^0-9]+', geo)
    xys.append(int(tmp[2]))
    xys.append(int(tmp[3]))
    xys.append(int(tmp[2])+int(tmp[0]))
    xys.append(int(tmp[3])+int(tmp[1]))
    return
